import salseApi from "@/api/declaration/erp/salseApi"
import httpRequest from "@/config/axios/httpRequest"
import { SaleOrderModel } from "@/models/erp/SaleOrderModel"




// ERP 销售订单 API
export const SaleOrderApi = {
  // 查询销售订单分页
  getSaleOrderPage: async (params: any) => {
    return await httpRequest.get<SaleOrderModel[]>(salseApi.GetSaleOrderPage, { params })
  },

  // 查询销售订单详情
  getSaleOrder: async (id: number) => {
    return await httpRequest.get(salseApi.GetSaleOrder, { params: { id } })
  },

  // 新增销售订单
  createSaleOrder: async (data: SaleOrderModel) => {
    return await httpRequest.post(salseApi.CreateSaleOrder, data)
  },

  // 修改销售订单
  updateSaleOrder: async (data: SaleOrderModel) => {
    return await httpRequest.put(salseApi.UpdateSaleOrder, data)
  },

  // 更新销售订单的状态
  updateSaleOrderStatus: async (id: number, status: number) => {
    return await httpRequest.put(salseApi.UpdateSaleOrderStatus, { id, status })
  },

  // 删除销售订单
  deleteSaleOrder: async (ids: number[]) => {
    return await httpRequest.delete(salseApi.DeleteSaleOrder, { data: { ids } })
  },

  // 导出销售订单 Excel
  exportSaleOrder: async (params: any) => {
    return await httpRequest.download(salseApi.ExportSaleOrder, params)
  }
}
